home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Game-Power
/
Amiga Game-Power.iso
/
pd mix ii
/
click to front
/
terrain_3-d
/
enq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-20
|
8KB
|
230 lines
/* *************************************************************************
The modified code in the appended section was extracted from
MENUS, REQUESTORS, AND GADGETS
BY
John T. Draper
A service from the Programmers Network
on the WELL in Sausalito.
Article 408@well and 409@well
December 31, 1985
Permission to post this on other networks is granted provided the
source of this information is included. The programmers network is
a non-profit network exchange of programming information. For more
information, mail your requests to:
WELL: crunch orsomewellprogrammerwhosequipmenthasnotbeenseized
BIX: crunch orsomewellprogrammerwhosequipmenthasnotbeenseized
USENET: ihnp4!ptsfa!well!crunch orsomewellprogrammerwhosequipmenthasnotbeenseized
DELPHI: crunch orsomewellprogrammerwhosequipmenthasnotbeenseized
************************************************************************* */
/*
* Hacked to make autoEnquirer, a positionable position-tracking requester
*
* Date: July 11, 1987
* Barbarian: Howard Hull
* Implements: custom requester code from John Draper's gadget tutorial
* + blood, sweat, tears, & additions to the explative list...
*/
/* **********************************************************
*
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* :: When you're a tiger trainer, it's a bad deal when ::
* :: the tiger gets your attention by putting a paw in ::
* :: your face. This is not only because tiger paws ::
* :: don't smell very good - it's also because you'll ::
* :: shortly begin to wonder what the rest of the tiger ::
* :: is up to. With that paw in your face, you can't ::
* :: determine what you need to know to decide on what ::
* :: ought to be done next. With tigers, it's much the ::
* :: same as it is with anything else: As Will Rogers ::
* :: once said, "It ain't what we know that gets us in ::
* :: trouble. It's what we know that ain't so..." ::
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*
*
* I wrote this thing up because I got tired of moving the requester
* out of the way so I could see what was going on, and that in turn
* so that I could then decide what to do with the requester. As all
* of you by now know, and as is evident in the net programs, if you
* make an AutoRequest, you get a requester at 0,0 with no programmable
* options to reposition it anywhere that you'd rather it be put. (Correct?)
*
* Given that the Gadget Editor Boys have not yet released their product
* (I think they are waiting for John Draper's life to get a little less
* complicated) I thought I'd put this out in the mean time. As I'm very
* much a C programming novice, I'm putting this up for some presumably
* critical guidance. Rather than being an example of proper code, I'm
* certain it contains a number of spectacular boo boos - maybe including
* some assumptions that would make the whole program completely unnecessary.
* Just as John said, requesters are a pain in the *ss. But without a
* gadget editor, this is the sort of thing that has to be done...
*
*/
#include "atv3d.h"
extern short wleftedge; /* These are the variables in which we */
extern short wtopedge; /* put the first received positions. */
extern struct IntuiText negtext; /* Let the user keep the button names in */
extern struct IntuiText postext; /* in his stuff, like for AutoRequest */
struct Requester req; /* custom requester structure */
/*
* Above is an instance of the (empty) Requester stucture. It contains a
* pointer to the host window through the RWindow structure. (The empty
* Requester structure was defined just above this comment. It is not
* declared, since it gets wiped clean by the InitRequester() call in the
* user's program. That call could be moved into this section if the user
* didn't have to follow through by initializing the structure before it
* can be used.
*/
/*
* In the RWindow structure containing the window's LeftEdge - TopEdge
* definition, we wish to keep track of the requester position by means
* of these two numbers once they are initialized. This structure is
* housed in the user's section.
*/
short autoEnquire(); /* the enquirer subroutine is in this section */
/***************************************************************************
* I M P O R T A N T C O N S T A N T S
***************************************************************************/
#define NL 0
#define REDP 3
#define BLKP 2
#define WHTP 1
#define BLUP 0
/***************************************************************************
CUSTOM REQUEST WITH TEXT, BORDERS, AND GADGETS
***************************************************************************/
/* Border for buttons */
SHORT Pairs[] = {
0, 0, /* Coordinates relative to button position definition */
43, 0,
43, 12,
0, 12,
0, 0
};
#define NUM_PAIRS 5 /* 5 pairs make a rectangle, start and stop incl */
struct Border butt_border = {
-1, -1,
BLUP, 0, JAM1,
NUM_PAIRS,
(SHORT *) Pairs,
NULL
};
/* FALSE BUTTON */
#define ONE_BUTT 1 /** GadgetID used to identify the action ***/
struct Gadget offgad = {
NULL,
7, 42, /* LeftEdge, TopEdge */
42, 11, /* Width, Height */
GADGHCOMP, /* Flag */
RELVERIFY | ENDGADGET, /* Activation */
BOOLGADGET | REQGADGET, /* GadgetType */
(APTR)&butt_border, /* GadgetRender - Border */
NULL, /* SelectRender */
&negtext, /* "OK" text */
NL, NL, ONE_BUTT, NL /* Mut Excl, Spec Info, */
};
/* TRUE BUTTON */
#define TWO_BUTT 2
struct Gadget ongad = {
&offgad,
7, 22, /* LeftEdge, TopEdge */
42, 11, /* Width, Height */
GADGHCOMP, /* Flag */
RELVERIFY | GADGIMMEDIATE, /* Activation */
BOOLGADGET | REQGADGET, /* GadgetType */
(APTR)&butt_border, /* GadgetRender - Border */
NULL, /* SelectRender */
&postext, /* "OK" text */
NL, NL, TWO_BUTT, NL /* Mut Excl, Spec Info, */
};
/* Outside Border of Requester */
SHORT ReqPairs[] = {
3, 3, /* Coordinates relative to requester sheet top left corner */
53, 3,
53, 57,
3, 57,
3, 3
};
struct Border out_border = {
-1, -1,
BLKP, 0, JAM1,
NUM_PAIRS,
(SHORT *) ReqPairs,
NULL
};
/***************************************************************************
D O C U S T O M R E Q U E S T
***************************************************************************/
/*
* Just as Enquiring minds want to know, Enquiring eyes want to see...
*/
autoEnquire()
{
short looping = TRUE;
short response = FALSE;
struct IntuiMessage *mes;
struct Gadget *gad; /* Gadget chosen */
unsigned long class;
while (looping)
{
if ((mes = (struct IntuiMessage *)GetMsg(RWindow->UserPort)) == 0L)
{
(VOID) Wait(1L<<RWindow->UserPort->mp_SigBit);
continue;
}
class = mes->Class;
gad = (struct Gadget *)mes->IAddress;
(VOID) ReplyMsg(mes);
if (class == REQCLEAR)
looping = FALSE;
if (class == GADGETDOWN)
{
switch (gad->GadgetID)
{
case TWO_BUTT: response = (short)TWO_BUTT-1;
EndRequest(&req, RWindow);
break;
case ONE_BUTT: response = (short)ONE_BUTT-1;
EndRequest(&req, RWindow);
break;
/* As you can see, adding more buttons would be easy */
}
}
}
wleftedge = RWindow->LeftEdge; /* This is where we track position */
wtopedge = RWindow->TopEdge; /* of the requester if it was moved */
return (response);
}